package main

import (
	"fmt"
	"github.com/golang/protobuf/proto"
	"io"
	proto1 "mock/gin_test/ch03/proto"
	"net/http"
)

func main() {

	//url := "http://127.0.0.1:8888/demo/moreJSON"
	url := "http://127.0.0.1:8888/demo/someProtoBuf"

	request, err := http.NewRequest("GET", url, nil)
	if err != nil {
		fmt.Println("request err:", err.Error())
	}
	response, err := http.DefaultClient.Do(request)
	if err != nil {
		fmt.Println("do err:", err.Error())
	}

	defer response.Body.Close()

	body, _ := io.ReadAll(response.Body)
	//fmt.Println(string(body))

	var teacher proto1.Teacher
	_ = proto.Unmarshal(body, &teacher)
	fmt.Println(teacher.Name, teacher.Course)
}
